<?php
if (!empty($model->title))
    Yii::app()->clientScript->registerMetaTag($model->title, 'og-title', null, array('property'=>'og:title'));
if (!empty($model->type))
    Yii::app()->clientScript->registerMetaTag($model->type, 'og-type', null, array('property'=>'og:type'));
if (empty($model->url))
    $url = Yii::app()->request->getUrl();
else
    $url = $model->url;
//convert relative to absolute
if (stripos($url,'http://') === false)
{
    $url = Yii::app()->getRequest()->hostInfo.'/'.ltrim($url, '/');
}
Yii::app()->clientScript->registerMetaTag($url, 'og-url', null, array('property'=>'og:url'));
if (!empty($model->image))
{
    $image = $model->image;
    //convert relative to absolute
    if (stripos($image,'http://') === false)
    {
        $image = Yii::app()->getRequest()->hostInfo.'/'.ltrim($image, '/');
    }
    Yii::app()->clientScript->registerMetaTag($image, 'og-image', null, array('property'=>'og:image'));
}
if (!empty($model->site_name))
    Yii::app()->clientScript->registerMetaTag($model->site_name, 'og-site_name', null, array('property'=>'og:site_name'));
if (!empty($model->description))
    Yii::app()->clientScript->registerMetaTag($model->description, 'og-description', null, array('property'=>'og:description'));